<?php
namespace app\api\model;

class User extends BaseModel{
    //关联地址
    public function address(){
        return $this->hasOne('user_address', 'user_id', 'id');
    }
    
    //获取用户
    public static function getByOpenID($openid){
        $user = self::where('openid', '=', $openid)
                ->find();
        return $user;
    }

    //创建用户
    public static function addUser($openid){
        self::create([
            'openid' => $openid
        ]);
        return $user->id;
    }

}


?>